#include "ScamperHandler.h"

extern std::vector<Router *> router_vector;

bool write_scamper_file ( const std::string& file_name )
{
	std::ofstream fileout (file_name.c_str(), std::ios::out|std::ios::trunc);
	if (!fileout)
		return 0;

	std::map<std::string, Router *>::iterator it;

	for ( it = Router::interface_map.begin() ; it != Router::interface_map.end() ; it++ )
		fileout << it->first << std::endl; 

	fileout.close();

	return 1;
}

int read_scamper_warts ( const std::string& file_name )
{
	scamper_file_t * in;
	scamper_file_filter_t * filter;
	uint16_t type;
	void * data;

	char * name = new char[file_name.length()+1];
	std::strcpy (name, file_name.c_str());

	uint16_t types[] = { SCAMPER_FILE_OBJ_TRACELB };

	if ((filter = scamper_file_filter_alloc(types, 1)) == NULL)
	{
		std::cout << "Scamper : could not allocate filter" << std::endl;
		return -1;
	}

	if ((in = scamper_file_open(name, 'r', NULL)) == NULL)
	{
		std::cout << "Scamper : could not open " << file_name << std::endl;
		return -1;
	}

	while (scamper_file_read(in, filter, &type, &data) == 0 )
	{
	}
	return 1;
}
